/**
 * 
 * VIEW OF ADJUST BAR
 * 
 * 2009-12-8
 * 
 * */
package com.components.adjustbar
{
	import core.section.Controller;
	
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.geom.Rectangle;

	public class AdjustBarView extends Controller
	{
		//START...
		
		//PROPERTY...
		
		internal var slider:MovieClip;
		
		internal var bar:MovieClip;
		
		//CONSTRUCTOR...
		public function AdjustBarView(target:DisplayObject)
		{
			
			super(target);
			
			init();
			
		}
		
		//METHODS...
		
		//initializing...
		private function init():void
		{
			
			var target:Sprite = this.target as Sprite;
			
			slider = target.getChildByName("slider") as MovieClip; 	
			
			slider.mouseEnabled = false;
			
			bar = target.getChildByName("bar") as MovieClip;
			
		}
		
		// bar start drag...
		internal function barStartDrag():void
		{
			
			bar.startDrag(false,new Rectangle(slider.x,bar.y,slider.width - bar.width,0));
																	
		}
		
		// bar stop drag...
		internal function barStopDrag():void
		{
			
			bar.stopDrag();
		
		}
		
		// set bar position...
		internal function setBarPosition(val:Number):void
		{
			
			bar.x = slider.x + slider.width * val;
						
		}
		
		
		//END...
	}
}